package com.art.wisdom.controller.menus;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.art.wisdom.api.menus.IMenusService;
import com.art.wisdom.model.DishesType;
import com.art.wisdom.util.Path;
import com.art.wisdom.util.Result;
import com.art.wisdom.util.ResultStatus;

/**
 * @auther : xiezhiwei
 * @description :
 * @email : xiezhiwei0314@126.com
 * @date : 2017-08-10
 */
@RestController
@RequestMapping(Path.ROOT)
public class MenusController {
	
	private Logger logger = LoggerFactory.getLogger(MenusController.class);
	
	@Autowired
	private IMenusService menusService;
	
	/**
	 * 获取菜单列表信息
	 * @param merchantId
	 * @param request
	 * @return
	 */
	@RequestMapping("/getSesameCateringMenusInfo")
	@ResponseBody
	public Map<String, Object> getMenusInfo(@RequestParam Long shopId, HttpServletRequest request){
		logger.info("获取菜单列表 merchantId = {}",shopId);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		try{
			Result<List<DishesType>> resultDishesType = menusService.getMenusInfo(shopId);
			logger.info("menusJson={}",JSON.toJSON(resultDishesType));
			resultMap.put("model", resultDishesType.getModel());
			resultMap.put("code", resultDishesType.getCode());
			resultMap.put("message", resultDishesType.getMessage());
		}catch (Exception e) {
			logger.info(e.getMessage());
			resultMap.put("code", ResultStatus.ERROR);
			resultMap.put("message", "获取菜单信息失败");
		}
		return resultMap;
	}
}
